package com.test.converter;

import java.util.Map;

import org.apache.struts2.util.StrutsTypeConverter;

import com.test.bean.Point;

public class PointConverter2 extends StrutsTypeConverter {

	public Object convertFromString(Map arg0, String[] arg1, Class arg2) {
			
		Point point = new Point();
		String[] paramValue = arg1[0].split(",");
		
		int x = Integer.parseInt(paramValue[0]);
		int y = Integer.parseInt(paramValue[1]);
		
		point.setX(x);
		point.setY(y);
		
		return point;
	}

	public String convertToString(Map arg0, Object arg1) {
	
		Point point =(Point)arg1;
		
		int x = point.getX();
		int y = point.getY();
		
		String result = "[ x = " + x + ", y = " + y + "]";
		
		return result;
	}

}
